import { Component, OnInit } from '@angular/core';
// import printJS from 'print-js';

@Component({
  selector: 'app-print',
  templateUrl: './print.component.html',
  styleUrls: ['./print.component.css'],
})
export class PrintComponent implements OnInit {
  constructor() {}
  data = {
    name: '小蓝',
    school: '暨南大学',
    major: '传媒专业',
    grade: '大二',
    sex: '女',
    nationality: '汉族',
    birthday: '2000-01-01',
    native_place: '广东广州',
    political: '党员',
    ID_number: '440754200001016422',
    // photo: 'https://wx3.sinaimg.cn/large/006APoFYly8hpjqsulxivj306o06oglj.jpg',
    photo: 'assets/images/photo.jpg',
    address: '广东省广州市广州大道289号广东省广州市广州大道289号',
    code: '510000',
    phone: '136xxxx2342',
    email: 'chaffy_zhen@126.com',
    emergency_contact_name: '小蓝她妈',
    emergency_contact_phone: '136xxxx6666',
    relationship: '母女',
    teacher_name: '小蓝她老师',
    teacher_phone: '137xxxx3333',
    education: [
      {
        qualification: '全日制本科',
        start_date: '2019-07-06',
        end_date: '2023-06-28',
        school: '暨南大学',
        departments: '传媒学院',
        major: '新闻传媒',
        grade: '大四',
      },
      {
        qualification: '研究生',
        start_date: '2023-09-02',
        end_date: '',
        school: '暨南大学',
        departments: '传媒学院',
        major: '新闻传媒',
        grade: '研一',
      },
    ],
    medium: '南方周末',
    post: '工程师',
    city: '广州',
    date: '2024-07-01至2024-10-01',

    internshipMedia: '南方周末',
    location: '广州',
    departmentOpinion: {
      department: '技术部',
      post: '工程师',
      startDate: '2025-01-10',
      endDate: '2023-03-10',
      mentor_1: '导师1',
      mentor_2: '导师2',
      approve:
        '老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了老棒了',
      signature: '',
      date: '2025-01-10',
    },
    humanResourcesOpinion: {
      signature: '',
      date: '2025-01-10',
    },
    notes:
      '备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注备注',
  };
  ngOnInit(): void {}
  onPrint() {
    // html2canvas(this.tablelist.nativeElement,{
    //   useCORS:true,
    //   width: this.tablelist.nativeElement.scrollWidth,
    //   height: this.tablelist.nativeElement.scrollHeight
    // }).then((canvas)=>{
    //   printJS({
    //     printable: canvas,
    //     type: 'html',
    //   });
    // })
    //  const link = document.createElement('link');
    //  link.rel = 'stylesheet';
    //  link.type = 'text/css';
    //  link.href = './print.css';
    //  link.media = 'print';
    //  // 将其添加到<head>中
    //  document.head.appendChild(link);

    // let dom: any = document.getElementById('print_table')
    // document.body.innerHTML = dom;
    window.print();
    // 打印后移除link元素
    // document.head.removeChild(link);
    // printJS({
    //   printable: dom,
    //   type: 'html',
    //   css: '/assets/css/print.css',
    // });
  }
}
